<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>富金银行花呗</title>
<link rel="icon" href="../images/logo_icon.png" type="image/x-icon"/>
<link href="${pageContext.request.contextPath }/admin/css/style.css"
	rel="stylesheet">
<link rel="shortcut icon" href="../favicon.ico">
<link
	href="${pageContext.request.contextPath }/admin/css/style-responsive.css"
	rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/diary/css/default.css" />

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/diary/css/component.css" />
<!-- PC调用的布局css -->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/index_pc_y.css"
	media=" screen and (min-width: 981px)" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/h_pc_y.css"
	media=" screen and (min-width: 981px)" />
<style type="text/css">
.h_nav {
	position: relative;
	z-index: 0;
	overflow:auto;
}
.h_nav_wrap {
    /* background: url(nav_bg.h_png) repeat-x; */
    height: 85px;
    position: relative;
    overflow: hidden;
    z-index: 0;
}
</style>
<script
	src="${pageContext.request.contextPath }/admin/js/jquery-1.10.2.min.js"></script>
<script
	src="${pageContext.request.contextPath }/diary/js/modernizr.custom.js"></script>
<script
	src="${pageContext.request.contextPath }/admin/js/bootstrap.min.js"></script>
<script type="text/javascript">
	function showSuccessModal() {
		$('#showSuccessModel').modal('show');
	}
	function showDiaryList() {
		var url = "${pageContext.request.contextPath }/user/selectAllDiarys.do";
		$.ajax({
			type : "post",
			url : url,
			dataType : 'json',
			success : function(result) {
				var dataObj = result; //返回的result为json格式的数据
				var datas = "<li>";
				$.each(dataObj, function(index, diary) {
					datas += "<time class='cbp_tmtime' >";
					datas += "<span>" + diary.dDay + "</span>";
					datas += "<span>" + diary.dMinute + "</span></time>";
					datas += "<div class='cbp_tmicon cbp_tmicon-phone'></div>";
					datas += "<div class='cbp_tmlabel'>";
					datas += "<h2>" + diary.dTitle + "</h2>";
					datas += "<p>" + diary.dContent + "</p>";
					datas += "</div>";

				});
				datas += "</li>"
				$("#diaryList").html(datas);
			},
			error : function() {
				alert("失败");
			}
		});
	}

	function addDiary() {
		$.ajax({
			cache : true,
			type : "POST",
			url : "${pageContext.request.contextPath }/user/addDiary.do",
			data : $('#addDiaryForm').serialize(),
			success : function(data) {
				showSuccessModal();
				showDiaryList();
				$('#myModal').modal('hide');
			},
			error : function(request) {
				alert("addDiary error");
			}
		});
	};
</script>
<style type="text/css">
body {
	background: #ffffff;
	overflow: auto;
}
</style>
</head>

<body onload="showDiaryList()">
	<!--最上方占位横条-->
	<div class="h_header_pc pc">
		<div align="right"
			style="margin-right: 50px; margin-top: 10px; font-size: 120%;">
			用户名：
			<c:set var="flag" value="请登录" />
			<c:if test="${not empty sessionScope.user.uName}">
				<c:set var="flag" value="${sessionScope.user.uName}" />
			</c:if>

			<a href="<c:url value="/user/showLoginPage.do"/>"
				style="color: blue;"> <c:out value="${flag}" />
			</a>
		</div>
	</div>

	<!----------------导航栏和logo--------------->

	<div class="cf h_nav_wrap pc h_nav_wrapNbg">
		<!--导航定位-->
		<div class="h_nav">
			<div class="h_logo fl">
				<a href="<c:url value="/index.jsp"/>"> <img
					src="../images/logo_ue2.png">
				</a>
			</div>
			<!--start-->
			
				<!--end-->
		</div>
	</div>
	<!----------------end 导航栏和logo--------------->
<div style="height:5px;background-color: #3BBDA9;margin-top: 10px;"></div>
	<div class="container">

		<header class="clearfix"> <span>Blueprint</span>

		<h1>钱都去哪啦......</h1>
		<div class="row">
			<div class="col-md-4" align="right"></div>
			<div class="col-md-5" align="right">
				<button type="button" style="background-color: #6CBFEE;" class="btn btn-primary " data-toggle="modal"
					data-target="#myModal">添加日记</button>
			</div>

		</div>
		</header>

		<div class="main">
			<ul class="cbp_tmtimeline" id="diaryList">
			</ul>

		</div>

	</div>

	<!--  模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true" position="fixed">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">日记</h4>
				</div>
				<div class="modal-body">
					<form class="bs-example bs-example-form" role="form"
						id="addDiaryForm">
						<div class="input-group">
							<span class="input-group-addon">标题：</span> <input type="text"
								name="dTitle" class="form-control" placeholder="标题">
						</div>
						<br>
						<div class="form-group">
							<label for="name">内容：</label>
							<textarea class="form-control" rows="3" name="dContent"></textarea>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="button" class="btn btn-primary" onclick="addDiary()">提交</button>
				</div>
			</div>
			<!-- .modal-content -->
		</div>
	</div>
	<!-- /.modal -->
	<%@include file="../admin/common/showSuccessModel.jsp"%>
</body>


</html>